<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>质检日报表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
	<style type="text/css">
	</style>
</head>
<body>
<form class="layui-form layui-card-body">
<table class="layui-table">
	<thead>
		<tr>
			<th style="text-align:center" colspan="2">
				<h2>质检报表</h2>
			</th>
		</tr>
		<tr>
			<th colspan="2">
				<span>报表周期</span>
				<div class="layui-inline" style="width: 182px">
					<select id="keyword" lay-filter="keyword">
						<option value="-1">--请选择--</option>
						<option value="1">日报表</option>
						<option value="7">周报表</option>
						<option value="30">月报表</option>
					</select>
				</div>
			</th>
		</tr>
	</thead>
	<tbody id="tbody">
		<tr>
			<td>
				<span>报检总数</span>
				<div class="layui-inline">
					<input readonly class="layui-input" name="bjCount" id="bjCount" style="display: inline"/>
				</div>
			</td>
			<td>
				<span>待检总数</span>
				<div class="layui-inline">
					<input readonly class="layui-input" name="djCount" id="djCount" style="display: inline"/>
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<span>合格数量</span>
				<div class="layui-inline">
					<input readonly class="layui-input" name="betterCount" id="betterCount" style="display: inline"/>
				</div>
			</td>
			<td>
				<span>返工数量</span>
				<div class="layui-inline">
					<input readonly class="layui-input" name="reworkCount" id="reworkCount" style="display: inline"/>
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<span>报废数量</span>
				<div class="layui-inline">
					<input readonly class="layui-input" name="badCount" id="badCount" style="display: inline"/>
				</div>
			</td>
			<td>
				<span>降级数量</span>
				<div class="layui-inline">
					<input readonly class="layui-input" name="demotion" id="demotion" style="display: inline"/>
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<span>让步接收数量</span>
				<div class="layui-inline">
					<input readonly class="layui-input" name="concession" id="concession" style="display: inline"/>
				</div>
			</td>
			<td>
			</td>
		</tr>
	</tbody>
</table>
<input style="color:red" class="layui-input" value="* 注：此报表包含配件与产品的检验信息"/>
</form>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
<script type="text/javascript">
//日期格式转换
function createTime(v){
	var date = new Date(v);
    var y = date.getFullYear();
    var M = date.getMonth()+1;
    M = M<10?'0'+M:M;
    var d = date.getDate();
    d = d<10?("0"+d):d;
    var h = date.getHours();
    h = h<10?("0"+h):h;
    var m = date.getMinutes();
    m = m<10?("0"+m):m;
    var str = y+"-"+M+"-"+d+" "+h+":"+m;
    return str;
}
//日期格式转换
function date2String(timestamp){
	var d = new Date(timestamp);
	var date = (d.getFullYear()) + "-" + 
       (d.getMonth() + 1<10?"0"+(d.getMonth() + 1):d.getMonth() + 1) + "-" +
       (d.getDate()<10?"0"+d.getDate():d.getDate()) + " " + 
       (d.getHours()<10?"0"+d.getHours():d.getHours()) + ":" + 
       (d.getMinutes()<10?"0"+d.getMinutes():d.getMinutes()) + ":" + 
       (d.getSeconds()<10?"0"+d.getSeconds():d.getSeconds());
       
       return date;
}
layui.use(['table','layer','upload','form', 'layedit', 'laydate'], function(){
	var table = layui.table;
	var layer = layui.layer
    ,form = layui.form
    ,layedit = layui.layedit
    ,laydate = layui.laydate;
	//条件查询
	form.on('select(keyword)', function(data){
		var keyword = $("#keyword").val();
		$.ajax({
			type:'post'
			,url:'${pageContext.request.contextPath }/daily/selectDailyByDate.do'
			,data:{'keyword':keyword}
			,dataType:'json'
			,success:function(res){
				//console.log(res)
				$("#bjCount").val(res.bjCount);
				$("#betterCount").val(res.betterCount);
				$("#reworkCount").val(res.reworkCount);
				$("#badCount").val(res.badCount);
				$("#demotion").val(res.demotion);
				$("#concession").val(res.concession);
				if(keyword==-1){
					$("#djCount").val("");
				}else{
					$("#djCount").val(Number(res.bjCount)-Number(res.betterCount)-Number(res.reworkCount)-Number(res.badCount)-Number(res.demotion)-Number(res.concession)<0?0:Number(res.bjCount)-Number(res.betterCount)-Number(res.reworkCount)-Number(res.badCount)-Number(res.demotion)-Number(res.concession));
				}
			}
		})
	 });
});
</script>
</body>
</html>